import request from './request.js'
import { Decrypt } from '@/utils/aes.js'

// 获取标签课程
export function queryCourse(params){
    return request({
        url:'/api/course/search',
        method:'POST',
        data:params,
        header:{
            'Content-Type':'application/json'
        }
    })
}

//获取新上好课数据(查询最新课程)
export function getNewCourse(params){
    return request({
        url:'/api/course/mostNew',
        method:'POST',
        data:params,
        header:{
            'Content-Type':'application/json'
        }
    })
}

//课程详情
export function getcourseInfo(courseId){
    return request({
        url:'/api/course/getDetail',
        method:'GET',
        params:{courseId}
    })
}

//播放课程
export function playCourse(courseId,chapterId){
    return request({
        url:'/api/player/play',
        method:'GET',
        params:{courseId,chapterId},
        headers:{
            // 本地保存的accessToken
            'Authorization': Decrypt(localStorage.getItem('token'))
        }
    })
}